package com.fpost.manager;

import java.util.List;

import org.hibernate.HibernateException;

import com.fpost.dao.impl.IpDAO;
import com.fpost.domain.Ip;

public class IpManager {
	
	public Long save(Ip ip) throws HibernateException {
		IpDAO dao = new IpDAO();
		return dao.save(ip);
	}

	public void saveOrUpdate(Ip ip) throws HibernateException {
		IpDAO dao = new IpDAO();
		dao.saveOrUpdate(ip);
	}

	public void delete(long id) throws HibernateException {
		IpDAO dao = new IpDAO();
		dao.delete(id);
	}

	public void delete(Ip ip) throws HibernateException {
		IpDAO dao = new IpDAO();
		dao.delete(ip);
	}

	public Ip get(long id) throws HibernateException {
		IpDAO dao = new IpDAO();
		return dao.get(id);
	}
	
	public List<Ip> getIpsByArticleId(long articleId) {
		IpDAO dao = new IpDAO();
		return dao.getIpsByArticleId(articleId);
	}
	
	public boolean isNewIpAddress(long articleId, String ipAddress) {
		IpDAO dao = new IpDAO();
		return dao.isNewIpAddress(articleId, ipAddress);
	}
}
